package com.tecniplast.selene.service.impl;

import java.util.Date;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.tecniplast.selene.common.util.MessageUtils;
import com.tecniplast.selene.dao.WeixinDao;
import com.tecniplast.selene.pojo.TextMessage;
import com.tecniplast.selene.service.WeixinService;

@Service("weixinService") 
public class WeixinServiceImpl implements WeixinService {
	@Resource
	 private WeixinDao weixinDao;
	 
	/**
	 输入返回结果
	 */
	@Override
	public String msgInfo(Map<String, String> map) {
		String  returnStr = "";
		//获取微信平台传递参数
		String fromUserName = map.get("FromUserName");
		String toUserName = map.get("ToUserName");
		String content = map.get("Content");
//		String msgType = map.get("MsgType");
		
		//获取代码表参数信息
		
		
		if("1,2".contains(content)){
			//公司简介
			TextMessage text = new TextMessage();
			text.setFromUserName(toUserName);
			text.setToUserName(fromUserName);
			text.setMsgType(MessageUtils.MESSAGE_TEXT);
			text.setCreateTime(new Date().getTime());
			String info = weixinDao.queryMsgById(Long.parseLong(content));
			text.setContent(info);
			returnStr = MessageUtils.textMessageToXml(text);
		}
		
		return returnStr;
	}
}
